home *** CD-ROM | disk | FTP | other *** search
- ;----------------------------------------------------------------------------
- ; Includes for CNET CN40-BC PCMCIA network card
- ;----------------------------------------------------------------------------
- ; Original code by Bruce Abbott (bhabbott@inhb.co.nz)
- ;
- ; "Some PC oriented eight (8) bit cards may require you read
- ; odd-byte I/O address registers at the corresponding even-byte
- ; address plus 64K. There is sufficient I/O address space
- ; provided that exceeding I/O address space should not be a problem."
- ;
- ; (extract from Autodoc 'cardresource.doc')
- ;
- ; The following information applies to the CNet CN40BC. Other cards could
- ; be quite different.
- ;
- ; Even byte addresses start at $a20000, and are mirrored every 1K.
- ; Odd byte addresses start at $a30000. By positioning the base I/O address
- ; 1K below the start of odd addressing, we can access both even and odd
- ; I/O space using a single CPU Address Register (with 16 bit offsets).
- ;
-
- ;IObase EQU $10000-$0400+$0300 ; offset to even nic registers
- ;odd EQU $10000-IOBase+$0300-1 ; offset to odd nic registers
-
-
- ;-----------------------------------------------------------------------
- ; The CNET CN40-BC uses a controller chip that is compatible with
- ; National Semiconducter's DS8390. This is the same chip that is
- ; used in NE1000 and NE2000 ISA bus ethernet cards.
-
- ; --------------------- DS8390 registers ------------------------
- ; registers in bank 0
- nic_cr EQU 0 ; command register (r/w) in all banks
- nic_pstart EQU 1 ; page start (w)
- nic_pstop EQU 2 ; page stop (w)
- nic_clda0 EQU nic_pstop ; current local dma addr (r)
- nic_bnry EQU 3 ; boundary pointer (r/w)
- nic_clda1 EQU nic_bnry ; current local dma addr (r)
- nic_tpsr EQU 4 ; transmit page start (w)
- nic_tsr EQU nic_tpsr ; transmit status register (r)
- nic_tbcr0 EQU 5 ; transmit byte count (w)
- nic_ncr EQU nic_tbcr0 ; number of collisions (r)
- nic_tbcr1 EQU 6 ; transmit byte count (w)
- nic_fifo EQU nic_tbcr1 ; fifo contents (r)
- nic_isr EQU 7 ; interrupt status (r/w)
- nic_rsar0 EQU 8 ; remote start address (w)
- nic_crda0 EQU nic_rsar0 ; current remote DMA addr (r)
- nic_rsar1 EQU 9 ; remote start address (w)
- nic_crda1 EQU nic_rsar1 ; current remote DMA addr (r)
- nic_rbcr0 EQU 10 ; remote byte count (w)
- nic_rbcr1 EQU 11 ; remote byte count (w)
- nic_rcr EQU 12 ; receive configuration (w)
- nic_rsr EQU nic_rcr ; receive status (r)
- nic_tcr EQU 13 ; transmit configuration (w)
- nic_cntr0 EQU nic_tcr ; tally counter (r) frame align errors
- nic_dcr EQU 14 ; data configuration (w)
- nic_cntr1 EQU nic_dcr ; tally counter (r) crc errors
- nic_imr EQU 15 ; interrupt mask (w)
- nic_cntr2 EQU nic_imr ; tally counter (r) missed packets
-
- ; bank 1 and 2 registers
- nic_par0 EQU 1 ; physical etheraddress (r/w)
- nic_par1 EQU 2 ; physical etheraddress (r/w)
- nic_par2 EQU 3 ; physical etheraddress (r/w)
- nic_par3 EQU 4 ; physical etheraddress (r/w)
- nic_par4 EQU 5 ; physical etheraddress (r/w)
- nic_par5 EQU 6 ; physical etheraddress (r/w)
- nic_curr EQU 7 ; current page (r/w)
- nic_mar0 EQU 8 ; multicast etheraddress (r/w)
- nic_mar1 EQU 9 ; multicast etheraddress (r/w)
- nic_mar2 EQU 10 ; multicast etheraddress (r/w)
- nic_mar3 EQU 11 ; multicast etheraddress (r/w)
- nic_mar4 EQU 12 ; multicast etheraddress (r/w)
- nic_mar5 EQU 13 ; multicast etheraddress (r/w)
- nic_mar6 EQU 14 ; multicast etheraddress (r/w)
- nic_mar7 EQU 15 ; multicast etheraddress (r/w)
-
- ; ASIC registers in the NE2000 card
- nic_data EQU 16 ; DMA port (r/w) 16 bit
- nic_rst EQU 31 ; card reset (r=reset, w=not)
-
- ; DS8390 command bits
- DSCM_STOP EQU $01 ; Stop controller
- DSCM_START EQU $02 ; Start controller
- DSCM_TRANS EQU $04 ; Transmit packet
- DSCM_RREAD EQU $08 ; Remote read (read from nic memory to Amiga memory)
- DSCM_RWRITE EQU $10 ; Remote write (write from Amiga memory to nic memory)
- DSCM_NODMA EQU $20 ; No Remote DMA present
- DSCM_PG0 EQU $00 ; Select register bank 0
- DSCM_PG1 EQU $40 ; Select register bank 1
- DSCM_PG2 EQU $80 ; Select register bank 2
-
- ; tansmit status register values
- DSTS_PTX EQU $01 ; Successful packet transmit
- DSTS_COLL EQU $02 ; Packet transmit w/ collision
- DSTS_COLL16 EQU $04 ; Packet had >16 collisions & fail
- DSTS_UND EQU $20 ; FIFO Underrun on transmission
-
- ; interrupt status register values
- DSIS_RX EQU $01 ; Successful packet reception
- DSIS_TX EQU $02 ; Successful packet transmission
- DSIS_RXE EQU $04 ; Packet reception w/error
- DSIS_TXE EQU $08 ; Packet transmission w/error
- DSIS_ROVRN EQU $10 ; Receiver overrun in the ring
- DSIS_CTRS EQU $20 ; Diagnostic counters need attn
- DSIS_RDC EQU $40 ; Remote DMA Complete
- DSIS_RESET EQU $80 ; Reset Complete
-
- ; interrupt mask register values
- DSIM_PRXE EQU $01 ; Packet received enable
- DSIM_PTXE EQU $02 ; Packet transmitted enable
- DSIM_RXEE EQU $04 ; Receive error enable
- DSIM_TXEE EQU $08 ; Transmit error enable
- DSIM_OVWE EQU $10 ; Overwrite warning enable
- DSIM_CNTE EQU $20 ; Counter overflow enable
- DSIM_RDCE EQU $40 ; Remote DMA complete enable
- DSIM_RESET EQU $80 ; Reset Complete enable
-
- ; Bit numbers for interrupts (same for int status and mask)
- DSIB_RX EQU 0
- DSIB_TX EQU 1
- DSIB_RXE EQU 2
- DSIB_TXE EQU 3
- DSIB_ROVRN EQU 4
- DSIB_CTRS EQU 5
- DSIB_RDC EQU 6
- DSIB_RESET EQU 7
-
- INTMASK EQU $ff&~(DSIM_RESET|DSIM_RDCE) ; all ints except DMA, Reset complete
-
-
- ; data configuration register values
- DSDC_WTS EQU $01 ; Word Transfer Select
- DSDC_BOS EQU $02 ; Byte Order Select
- DSDC_LAS EQU $04 ; Long Address Select
- DSDC_BMS EQU $08 ; Burst Mode Select
- DSDC_AR EQU $10 ; Autoinitialize Remote
- DSDC_FT0 EQU $20 ; Fifo Threshold Select
- DSDC_FT1 EQU $40 ; Fifo Threshold Select
-
- ; receive status register values
- DSRS_RPC EQU $01 ; Received Packet Complete
-
- ; transmit configuration register values
- DSTC_CRC EQU $01 ; Inhibit CRC
- DSTC_LB0 EQU $02 ; Encoded Loopback Control
- DSTC_LB1 EQU $04 ; Encoded Loopback Control
- DSTC_ATD EQU $08 ; Auto Transmit Disable
- DSTC_OFST EQU $10 ; Collision Offset Enable
-
- ; receive configuration register values
- DSRC_SEP EQU $01 ; Save error packets
- DSRC_AR EQU $02 ; Accept Runt packets
- DSRC_AB EQU $04 ; Accept Broadcast packets
- DSRC_AM EQU $08 ; Accept Multicast packets
- DSRC_PRO EQU $10 ; Promiscuous physical
- DSRC_MON EQU $20 ; Monitor mode
-
-
- ;-------------------------------------------------------------------------
- ; Packet receive header, 1 per each buffer page used in receive packet.
- ; The nic inserts this in front of the received packet.
- ;
- STRUCTURE prhdr,0
- BYTE prhdr_status ; is this a good packet, same as ds0_rsr
- BYTE prhdr_nxtpg ; next page of packet or next packet
- BYTE prhdr_sz0 ; length (lower byte)
- BYTE prhdr_sz1 ; length (upper byte)
- LABEL prhdr_sizeof
-
- ;-------------------------------------------------------------------------
- ; nic has 16K of on-board RAM, from $4000 to $7fff (16 bit address)
- ;
- ; Internal DMA operations (ie. tx/rx) require the upper 8 bits of the
- ; address, as RAM is addressed in 256 byte pages.
- ;
- ; DMA to/from the host Amiga ("Remote DMA") requires a 16 bit word-aligned
- ; address
- ;
-
- PKTSZ EQU $0600 ; space for biggest ethernet packet (6 pages)
-
- TBUF EQU $4000 ; Starting location of Transmit Buffer
- TBUF1 EQU $4000+PKTSZ ; Another Tx Buffer (for double-buffered tx)
- RBUF EQU $4000+(PKTSZ*2) ; Starting location of Receive Ring Buffer
- RBUFEND EQU $8000 ; Ending location of Receive Ring Buffer
-
- ETHER_MIN_LEN EQU 64 ; smallest acceptable packet size
- ETHER_MAX_LEN EQU 1536 ; largest raw packet size
-
- ; ethernet packet data sizes (maximum)
-
- ETHERPKT_SIZE EQU 1500
- RAWPKT_SIZE EQU 1514
-
- ; size of our packet buffer
-
- PKTBUF_SIZE EQU 1600 ; actually only need 1536 ?
-
- ; ethernet address bytesize
-
- ETHER_ADDR_SIZE EQU 6
-
- ; structure of an ethernet packet
-
- STRUCTURE etherpacket,0
- STRUCT ether_dest,ETHER_ADDR_SIZE ; 0 destination address
- STRUCT ether_src,ETHER_ADDR_SIZE ; 6 originator address
- WORD ether_type ; 12 packet type
- LABEL ether_data ; 14 user data (up to 1500 bytes)
-
-
- ; our extension to device data
-
- STRUCTURE device_data,LIB_SIZE
- BYTE dd_flags ; various flags
- BYTE dd_dcr ; copy of nic data config reg
- BYTE dd_rcr ; copy of nic rx config reg
- BYTE dd_imr ; copy of nic intmask register
- LONG dd_overflows ; nic rx buffer overflow count
- LONG dd_errors ; bad packets received
- LONG dd_collisions ; tx collision count
- LONG dd_seglist ; device seglist
- APTR dd_copytobuf ; caller's read routine
- APTR dd_copyfrombuf ; caller's write routine
- APTR dd_pcires ; micronik_pci.resource base
- APTR dd_pcielib ; pciexpansion.library base
- APTR dd_mapping_main ; Mapping struct for main thread
- APTR dd_mapping_rx ; Mapping struct for rx int
- APTR dd_mapping_tx ; Mapping struct for tx int
- APTR dd_mapping_int ; Mapping struct for status int
- APTR dd_pciconfig ; card's PCI definition
- ; from pciexpansion.library
- STRUCT dd_romstationaddress,ETHER_ADDR_SIZE ; hardware address from ROM
- STRUCT dd_stationaddress,ETHER_ADDR_SIZE ; hardware station addr used
- STRUCT dd_readlist,MLH_SIZE ; read requests
- STRUCT dd_writelist,MLH_SIZE ; write requests
- STRUCT dd_eventlist,MLH_SIZE ; events
- STRUCT dd_netinterrupt,IS_SIZE ; interrupt
- STRUCT dd_txint,IS_SIZE ; transmit software interrupt
- STRUCT dd_rxint,IS_SIZE ; receive software interrupt
- LABEL dd_extsize
-
-
- ; bit definitions for dd_flags
-
- BITDEF DD,NICUP,2 ; controller hardware is initialised
- BITDEF DD,CONFIGURED,4 ; hardware address is configured
- BITDEF DD,ONLINE,5 ; device is online
- BITDEF DD,TX,6 ; transmit buffer is full
- BITDEF DD,DEVINIT,7 ; device is initialised
-